package cn.com.ebidding.dianjian.server.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

/**
 * Created by sehuaqi on 2017/7/6.
 */
@Repository
public class RedisDao {
    @Autowired
    private StringRedisTemplate redisTemplate;

    public void setKey(String key,String value){
        ValueOperations<String,String> ops = this.redisTemplate.opsForValue();
        ops.set(key,value);
    }

    public void setKey(String key,String value, long time){
        ValueOperations<String,String> ops = this.redisTemplate.opsForValue();
        ops.set(key,value,time);
    }

    public String getKey(String key){
        ValueOperations<String,String> ops = this.redisTemplate.opsForValue();
        return ops.get(key);
    }
}
